package com.example.mybackend.controller;


import com.example.mybackend.entity.user;
import com.example.mybackend.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
@CrossOrigin
public class userController {
    @Autowired
    private userService userService;

    @GetMapping("all")
    public List<user> getAllUsers() {
        return userService.selectAll();
    }

    @PutMapping("status0/{id}")
    public Integer set0(@PathVariable Integer id){
        return userService.updateStatusTo0(id);
    }
    @PutMapping("status1/{id}")
    public Integer set1(@PathVariable Integer id){
        return userService.updateStatusTo1(id);
    }

    @PutMapping("edit")
    public Integer edit(@RequestBody user User){
        return userService.updateUser(User);
    }

}
